Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-59330: Improve error message for dest= for positionals #125215

Merged

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Oct 9, 2024

Also improve the documentation. Specify how dest and metavar are derived from add_argument() positional arguments.


📚 Documentation preview 📚: https://cpython-previews--125215.org.readthedocs.build/

Also improve the documentation. Specify how dest and metavar are derived
from add_argument() positional arguments.

Co-authored-by: Simon Law <sfllaw@sfllaw.ca>
Copy link
Member

@savannahostrowski savannahostrowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one small comment about the documentation; otherwise, this LGTM!

I really like the additional error message specificity.

Doc/library/argparse.rst Outdated Show resolved Hide resolved
Comment on lines +639 to +645
By default, argparse automatically handles the internal naming and
display names of arguments, simplifying the process without requiring
additional configuration.
As such, you do not need to specify the dest_ and metavar_ parameters.
The dest_ parameter defaults to the argument name with underscores ``_``
replacing hyphens ``-`` . The metavar_ parameter defaults to the
upper-cased name. For example::
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
By default, argparse automatically handles the internal naming and
display names of arguments, simplifying the process without requiring
additional configuration.
As such, you do not need to specify the dest_ and metavar_ parameters.
The dest_ parameter defaults to the argument name with underscores ``_``
replacing hyphens ``-`` . The metavar_ parameter defaults to the
upper-cased name. For example::
By default, argparse automatically handles the internal naming and
display names of arguments, simplifying the process without requiring
additional configuration. As such, you do not need to specify the dest_
and metavar_ parameters. The dest_ parameter defaults to the argument
name with underscores ``_`` replacing hyphens ``-`` . The metavar_
parameter defaults to the upper-cased name. For example::

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just removing the newline as I think that this can be one short paragraph.

Copy link
Member Author

@serhiy-storchaka serhiy-storchaka Oct 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not affect the result. For Sphinx this is the same.

I prefer to start new sentence from a new line. This will help to keep the text more readable in future without reformatting the whole paragraph. Adding or removing will only affect one sentence.

I don't know if this is already in the style guide, but I try to follow this rule.

@serhiy-storchaka serhiy-storchaka merged commit a6c0c64 into python:main Oct 12, 2024
34 checks passed
@serhiy-storchaka serhiy-storchaka deleted the argparse-positional-dest branch October 12, 2024 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants